﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MSExcel = Microsoft.Office.Interop.Excel;

namespace TrackAnalyst.Lib
{
    public class MSCInfo
    {
        public static MSCInfo[] Load(string file)
        {
            MSExcel.Application app = new MSExcel.Application();
            MSExcel.Worksheet sheet = null;

            app.Workbooks.Open(file);

            sheet = app.Worksheets.get_Item(1);//第一页,


            int maxCol = sheet.UsedRange.Columns.Count;
            int maxRow = sheet.UsedRange.Rows.Count;

            MSCInfo[] mSCInfos = new MSCInfo[maxRow];
            List<MSCInfo> mSCInfoList = new List<MSCInfo>();

            for (int i = 2; i <= maxRow; i++)//下标从一开始
            {
                string name = sheet.Cells[i, 1].value.ToString();
                string gridname = sheet.Cells[i, 2].value.ToString();
                object o = sheet.Cells[i, 3];
                string mscid = sheet.Cells[i,3].value.ToString();
                MSCInfo tmpInfo = new MSCInfo();
                tmpInfo.Name = name;
                tmpInfo.GridName = gridname;
                tmpInfo.MSCID = mscid;
                mSCInfoList.Add(tmpInfo);             
            }
            int listCount = mSCInfoList.Count;
            if (listCount>0)
            {
                mSCInfos=mSCInfoList.ToArray<MSCInfo>();
            }
            return mSCInfos;
        }

        /// <summary>
        /// msc id
        /// </summary>
        public string MSCID { get; set; }
        /// <summary>
        /// 片区
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 网元名称
        /// </summary>
        public string GridName { get; set; }
        
    }
}
